package com.whmall.service.crm.module.company.convert;

import com.whmall.component.common.ObjectConverter;
import com.whmall.component.util.FieldUtils;
import com.whmall.service.crm.entity.dto.company.CompanyRspDTO;
import com.whmall.service.crm.module.company.entity.CompanyDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @Description TODO
 * @Author yangkuan
 * @Date 2020/8/5 14:56
 **/
@Component
public class CompanyDO2CompanyRspDTO implements ObjectConverter<CompanyDO, CompanyRspDTO> {

    @Override
    public CompanyRspDTO fillProperties(CompanyDO source, CompanyRspDTO dest) {

        if (null == dest) {
            dest = new CompanyRspDTO();
        }

        BeanUtils.copyProperties(source, dest);
        dest.setEstablishedTime(FieldUtils.unwrapDate(dest.getEstablishedTime()));
        dest.setCreateTime(FieldUtils.unwrapDate(dest.getCreateTime()));
        dest.setFirstOrderTime(FieldUtils.unwrapDate(dest.getFirstOrderTime()));
        dest.setLastOrderTime(FieldUtils.unwrapDate(dest.getLastOrderTime()));
        dest.setFirstInquiryTime(FieldUtils.unwrapDate(dest.getFirstInquiryTime()));
        dest.setLastInquiryTime(FieldUtils.unwrapDate(dest.getLastInquiryTime()));
        return dest;

    }
}
